sp

How to modify a polygon to be a hole (SpatialPolygons) changing its slots

喜欢而已 提交于 2019-12-02 02:23:21
Edit: As suggested by Edzer Pebesma in the comments, the recommended method to add a hole to a polygon is not to modify the slot but to rebuild the polygon, as illustrated in this related question . Original question Following the help of SpatialPolygons-class I tried to modify a polygon to be a hole of an other polygon but while the "hole polygon" is displayed as a border of the other polygon, its inside is colored as the rest. What am I doing wrong? Using defPunched and defHole defined here : library("sp") load(url("http://spatcontrol.net/CorentinMBarbu/misc/holeIssue.rda")) defHole@polygons

spatial interpolation error using idw

爱⌒轻易说出口 提交于 2019-12-01 09:43:04
I am trying to spatially interpolate a dataset of seawater pH by lat & long: sample<-read.csv(file="Station locations 2016.csv", header=TRUE, sep=",", strip.white=T) head(sample) Station lat long pH 1 B17 -23.49174 152.0718 8.222411 2 B23 -23.49179 152.0718 8.199310 3 B26 -23.49182 152.0717 8.140428 4 B28 -23.49183 152.0717 8.100752 5 B30 -23.49185 152.0717 8.068141 6 B31 -23.49187 152.0717 8.048852 I have created a grid based on the existing ranges in lat/long data and want to interpolate the pH values so that I can produce a color-coded map of pH. The following code works until the spatial

Filling polygons of a sp map object by another variable in R

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 09:04:40
问题 My goal is generating a Los Angles zipcode map filled by another variable, say number of crime events using ggplot. As the filling variable that is originally not stored in the sp object, the method suggested in here may not be used directly. First, I have a huge dataset called ztca which is a SpatialPolygonDataFrame and contains all polygons (one of the layers called ZCTA5CE10, contains the zip-codes that I work on) of USA from the US Census Bureau, the preparation of primary sp object is

Population-weighted polygon distortion (cartograms)

a 夏天 提交于 2019-11-30 21:21:31
问题 I'm trying to create a map in R that conveys both the shape of underlying geometry (i.e., the physical boundaries) and the relative importance of the object in terms of an associated value. For concreteness, I'd like to focus on reproducing (a version of) the following map* (the shapes , not so much the colors since I can't find the polling data): I also don't want to bother with getting Alaska and Hawaii to appear below the US instead of in their geodesically correct locations. I'm only as

Create SpatialPointsDataframe

不羁的心 提交于 2019-11-30 18:53:48
I have a dataframe df1 with 10 columns. Two of these columns are lng and lat . I want to create a SpatialPointsDataframe from df1 . When I read on how to create a SpatialPointsDataframe it feels like I have to create a matrix m1 from my two coordinates columns and then assign that matrix to the dataframe ´df1`. That would be a detour since my coordinates are already a column in my dataframe df1 . Furthermore, how do I assure that the coordinates from my matrix m1 are assign to the correct rows in my dataframe df1 ? thats how my df1 would look like > df1 a b c d e lat lng 1 12 f2 23 dd 2d 15.6

Android 第四课——AndroidManifest.xml

╄→尐↘猪︶ㄣ 提交于 2019-11-30 10:59:58
清单文件的具体介绍 在 Android 项目中,下一个重要的文件是清单文件。观察一下 AndroidManifest.xml 文 件的内容: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="net.learn2develop.HelloWorld" android:versionCode="1" android:versionName="1.0.0" > <uses-sdk android:minSdkVersion="14" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:label="@string/app_name" android:name=".HelloWorldActivity" > <intent-filter > <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.

Creating a regular polygon grid over a spatial extent, rotated by a given angle

我的梦境 提交于 2019-11-30 08:55:49
Hi all, I am struggling with this and hope someone could come out with a simple solution. My objective is to create a regular polygon grid over the extent of a polygon, but rotated by a user-defined angle . I know that I can easily create a North/South polygon grid in sf using for example: library(sf) #> Linking to GEOS 3.6.2, GDAL 2.2.3, proj.4 4.9.3 inpoly <- st_read(system.file("shape/nc.shp", package="sf"))[1,] %>% sf::st_transform(3857) %>% sf::st_geometry() grd <- sf::st_make_grid(inpoly, cellsize = 3000) plot(inpoly, col = "blue") plot(grd, add = TRUE) I also know that I can easily

How to add a hole to a polygon within a SpatialPolygonsDataFrame?

帅比萌擦擦* 提交于 2019-11-29 16:21:57
I have a list of polygons in a SpatialPolygonsDataFrame and need to set one of them as a hole in an other. I've found in the help of set_Polypath how a hole can be defined on a newly created polygon but how to set the "hole" flag on an existing polygon? It looks like you have to rebuild the polygon, and then replace it in the spdf. The following function automatically rebuild the polygon adding a hole: library("sp") AddHoleToPolygon <-function(poly,hole){ # invert the coordinates for Polygons to flag it as a hole coordsHole <- hole@polygons[[1]]@Polygons[[1]]@coords newHole <- Polygon

R: How can I count how many points are in each cell of my grid?

穿精又带淫゛_ 提交于 2019-11-29 11:19:30
I have made a reference grid, cells 50x50m, based on GPS locations of a collared animal. I want to do the equivalent to a spatial join in ArcGIS, and count the number of points in each cell. I have made a reference grid, using a SpatialPointsDataFrame object (the data frame is already projected, using UTM coordinate system) RESO <- 50 # grid resolution (m) BUFF <- 500 # grid extent (m) (buffer around location extremes) XMIN <- RESO*(round(((min(dat.spdf$Longitude)-BUFF)/RESO),0)) YMIN <- RESO*(round(((min(dat.spdf$Latitude)-BUFF)/RESO),0)) XMAX <- XMIN+RESO*(round(((max(dat.spdf$Longitude)