sp

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

老子叫甜甜 提交于 2019-12-20 03:44:03
问题 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:

spatial interpolation error using idw

喜夏-厌秋 提交于 2019-12-19 10:18:37
问题 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

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

泄露秘密 提交于 2019-12-18 06:54:45
问题 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

SpatialPolygons - Creating a set of polygons in R from coordinates

ε祈祈猫儿з 提交于 2019-12-17 10:46:25
问题 I am trying to take create a set of polygons from vertex locations, saved in X,Y format. Here is an example of my data - each row represents the vertices for one polygon. the polygons are squares square <- rbind(c(255842.4, 4111578, 255862.4, 4111578, 255862.4, 4111558, 255842.4, 4111558, 255842.4, 4111578, 255842.4, 4111578), c(257397.0, 4111309, 257417.0, 4111309, 257417.0, 4111289, 257397.0, 4111289, 257397.0, 4111309, 257397.0, 4111309)) ID <- c("SJER1", "SJER2")' I am using

MYSQL表关联删除

蹲街弑〆低调 提交于 2019-12-16 04:03:38
MYSQL表关联删除 #4张表关联删除 DELETE sp,sps,spt,sst FROM `sys_preset` sp LEFT JOIN sys_preset_type spt ON sp.type_id=spt.type_id LEFT JOIN sys_preset_scene sps ON sp.scene_id=sps.scene_id LEFT JOIN sys_stay_t sst ON sp.stay_id=sst.stay_id WHERE preset_id=3 来源: CSDN 作者: 草莓奶昔的甜 链接: https://blog.csdn.net/mws666/article/details/103496770

Changing CRS of a SF object

落花浮王杯 提交于 2019-12-14 01:50:23
问题 I have some 'roads' as a sp object: class : SpatialLinesDataFrame features : 17360 extent : 490176.4, 567680.9, 148639.1, 212821 (xmin, xmax, ymin, ymax) coord. ref. : +init=epsg:27700 +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +datum=OSGB36 +units=m +no_defs +ellps=airy +towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894 variables : 4 names : osm_id, lanes, type, width min values : 73, 2, motorway, 6.3 max values : 587969162, 6, trunk, 18.9 I convert

Turn extraction list to csv file

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 09:10:57
问题 I have uploaded a raster file and polyline shapefile into R and use the extract function to to extract the data from every pixel along the polyline. How do I turn the list output by extract into a CSV file? 回答1: If I understand what it is you're asking, I think you could resolve your situation by using unlist(). d <- c(1:10) # creates a sample data frame to use d <- as.list(d) # converts the data frame into a list d <- unlist(d) # converts the list into a vector 回答2: Always include a simple

R: Shouldn't generic methods work internally within a package without it being attached?

…衆ロ難τιáo~ 提交于 2019-12-13 07:48:13
问题 I am writing a package that uses classes and functions from the spatial sp library. sp exports methods for rbind (am I correct in calling rbind a generic?). For instance, the following code creates two SpatialPoints objects and then uses rbind.SpatialPoints to join them together: > crdsA <- matrix(c(1,2,3,4), ncol = 2) > crdsB <- matrix(c(7,8), ncol = 2) > > sptsA <- sp::SpatialPoints(crdsA) > sptsB <- sp::SpatialPoints(crdsB) > > sp::rbind.SpatialPoints(sptsA, sptsB) SpatialPoints: coords.x1

Extracting values from inside polygons raster r

三世轮回 提交于 2019-12-13 04:17:28
问题 I'm trying to find the mean daily temperature for counties in South Dakota from raster grids ('bil' files) found at http://prism.oregonstate.edu/. I am getting county boundaries from the 'maps' package. library(maps) library(raster) sd_counties <- map('county','south dakota') sd_raster <- raster('file_path') How do I extract the grid cells within each county? I think I need to turn each county into it's own polygon to do this, but how? Then, I should be able to do something like the following

How to compute greatest distance between polygon centroid and edge

邮差的信 提交于 2019-12-13 02:57:40
问题 I have a SpatialPolygons(DataFrame) object, e.g. SpP library(sp) Sr1 = Polygon(cbind(c(2,4,4,1,2),c(2,3,5,4,2))) Sr2 = Polygon(cbind(c(5,4,2,5),c(2,3,2,2))) Sr3 = Polygon(cbind(c(4,4,5,10,4),c(5,3,2,5,5))) Sr4 = Polygon(cbind(c(5,6,6,5,5),c(4,4,3,3,4)), hole = TRUE) Srs1 = Polygons(list(Sr1), "s1") Srs2 = Polygons(list(Sr2), "s2") Srs3 = Polygons(list(Sr3, Sr4), "s3/4") SpP = SpatialPolygons(list(Srs1,Srs2,Srs3), 1:3) I would like to, for each polygon, calculate the greatest distance between