Spatial

How to subset SpatialGrid using SpatialPolygon

一曲冷凌霜 提交于 2019-12-04 12:22:49
I am trying to subset the SpatialGrid with 1 polygon present in class SpatialPolygons . How can I do this? I tried it this way: grd.clip <- grd[!is.na(over(grd, polygon))] But I get error Error in matrix(idx, gr@cells.dim[2], gr@cells.dim[1], byrow = TRUE)[rows, : (subscript) logical subscript too long I've tried a way that turn out not to be the desired solution. I'll keep it here for illustrate my original idea but I'll willing to delete it if necessary The solution to the initial question still not clear to me but I'll make it better if necessary library(sp) library(rgdal) library(raster)

spatial clustering in R (simple example)

青春壹個敷衍的年華 提交于 2019-12-04 12:02:54
问题 I have this simple data.frame lat<-c(1,2,3,10,11,12,20,21,22,23) lon<-c(5,6,7,30,31,32,50,51,52,53) data=data.frame(lat,lon) The idea is to find the spatial clusters based on the distance First, I plot the map (lon,lat) : plot(data$lon,data$lat) so clearly I have three clusters based in the distance between the position of points. For this aim, I've tried this code in R : d= as.matrix(dist(cbind(data$lon,data$lat))) #Creat distance matrix d=ifelse(d<5,d,0) #keep only distance < 5 d=as.dist(d)

Smoothing of “spatial” data

可紊 提交于 2019-12-04 11:55:00
I have 2 variables x and y which are Cartesian coordinates at [0,1], and z is the value of a (continuous) variable at these coordinates. The z vector has some important outliers x<-sample(seq(0,1,0.001), replace=F) y<-sample(seq(0,1,0.001), replace=F) z<-runif(1001,min=0,max=1) z[100]<-8;z[400]<-16;z[800]<-4 These outliers I would like to emphasize when presenting these data in a filled.contour I have used until now library(akima) a<-interp(x,y,z) filled.contour(a$x,a$y,a$z) But I am not happy with this linear interpolation. For example (the outliers do not show up correctly). I am thinking

how do i create a circle Geometry with a radius and co-ordinates of center, using MySQL Spatial Extensions?

爷,独闯天下 提交于 2019-12-04 11:18:33
问题 I am trying to create a Circle Geometry in MySQL using the co-ordinates of the center and a radius. I searched everywhere...all i could find in the MySQL doc on the site were for polygons. May be i am looking in the wrong place. can anybody help me with an appropriate SQL that can help me create a table that stores this Circle geometry as one of the columns in the table? Also, i am not even sure if there is a way to do so in MySQL?..The version i am using is MySQL 5.6. Thanks in advance. 回答1:

How to count the number of elements in all Oracle varrays from table?

烂漫一生 提交于 2019-12-04 11:06:31
I have a table like this: CREATE TABLE spatial_data ( id NUMBER PRIMARY KEY, geometry SDO_GEOMETRY); SDO_GEOMETRY has a field sdo_ordinates with the following type: TYPE SDO_ORDINATE_ARRAY AS VARRAY(1048576) OF NUMBER I can get the number of points for specified object: select count(*) from table( select s.geometry.sdo_ordinates from spatial_data s where s.id = 12345 ); How can I get count for several objects? It's not possible to use where s.id in (1, 2, 3, 4, 5) And I really care about performance. Maybe PL/SQL would be the right choice? I think that you can do it with one query: select s.id

In R, how do I join and subset SpatialPolygonsDataFrame?

空扰寡人 提交于 2019-12-04 10:26:39
I'm trying to figure out my way on how to perform (so easy in GIS) operations in R. Let's take some example polygon data set from spdep package library("spdep") c <- readShapePoly(system.file("etc/shapes/columbus.shp", package="spdep")[1]) plot(c) I've managed to figure out that I can choose polygons with logical statements using subset . For instance: cc <- subset(c, c@data$POLYID<5) plot(cc) Now, let's suppose I have another data frame that I'd like to join to my spatial data: POLYID=1:9 TO.LINK =101:109 link.data <- data.frame(POLYID=POLYID, TO.LINK=TO.LINK) Using these two datasets, how

R - Fitting a grid over a City Map and inputting data into grid squares

女生的网名这么多〃 提交于 2019-12-04 10:21:38
I'm trying to place a grid over San Jose like this: Grid of San Jose You can make the grid visually using the following code: ca_cities = tigris::places(state = "CA") #using tigris package to get shape file of all CA cities sj = ca_cities[ca_cities$NAME == "San Jose",] #specifying to San Jose UTM_ZONE = "10" #the UTM zone for San Jose, will be used to convert the proj4string of sj into UTM main_sj = sj@polygons[[1]]@Polygons[[5]] #the portion of the shape file I focus on. This is the boundary of san jose #converting the main_sj polygon into a spatialpolygondataframe using the sp package tst_ps

st_intersects Vs st_overlaps

删除回忆录丶 提交于 2019-12-04 08:39:08
What is the difference between these two queries : select a.gid, sum(length(b.the_geom)) from polygons as a , roads as b where st_intersects(a.the_geom,b.the_geom) group by a.gid ; select a.gid, sum(length(b.the_geom)) from polygons as a , roads as b where st_overlaps(a.the_geom,b.the_geom) group by a.gid ; Where the first query is giving the correct output whereas the second query retrieves no rows at all. The road that intersects the polygons also overlaps it, right? From the documentation of PostGIS http://postgis.net/docs/ST_Intersects.html If a geometry or geography shares any portion of

Why can't I insert into MySQL?

大兔子大兔子 提交于 2019-12-04 08:15:35
+---------+---------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------+---------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | user_id | int(11) | NO | UNI | NULL | | | utm | point | NO | MUL | NULL | | +---------+---------+------+-----+---------+----------------+ insert into life(user_id, utm) values(99,point(4,4)); ERROR 1416 (22003): Cannot get geometry object from data you send to the GEOMETRY field Have you tried: insert into life(user_id, utm) values(99,PointFromWKB(POINT(4,4))); 来源: https:

Spatial data/Geography in SQL Server 2008, OR mappers and C#

扶醉桌前 提交于 2019-12-04 06:44:47
I'm developing an application in C# that will use and store geographic locations using the data type "Geography" in SQL Server 2008. I was planning to use the Entity Framework but soon discovered it lacks support for spatial data. Does anyone have experience with or know of other OR mappers with spatial support? The system will have few writes and many reads of geographical data. What is a good/preffered way to read/write spatial/Geography data from C#? Daniel Vassallo You may want to check out the following Stack Overflow post: Spatial data types support in Linq2Sql or EF4 . In addition, you