Spatial

R:Custom color palette in map with spplot

我的未来我决定 提交于 2019-12-21 20:46:30
问题 I am struggling with introducing a custom color palette on several polygons using spplot from the sp package. I am plotting several fields and want to show my rating , which can have the values 0,1,2,4 or 5. I need to use custom colors for that. What I tried is: spplot(Map,zcol="Rating", col.regions=c("0"="#00cc00","1"="#ffff66","2"="#e5c100", "3"="orange","4"="#ff5e5e","5"="red"), colorkey=TRUE) However, it is producing a repetition of colors like in the map below. How can I solve this? I

How do I insert a mysql spatial point with a yii model?

梦想的初衷 提交于 2019-12-21 20:44:30
问题 I have a model type that was generated from a mysql table that has address data and also a spatial POINT field named "coordinates". When a model is created or updated I want to geocode the address and store the latitude and longitude coordinates in the POINT field. My understanding is the way to do this is to geocode the address in the model's beforeSave method. I have done this and have the coordinates in an associative array. Now my question is how can I insert this data into my coordinates

How to subset SpatialGrid using SpatialPolygon

夙愿已清 提交于 2019-12-21 20:27:41
问题 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 回答1: 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

Why can't I insert into MySQL?

淺唱寂寞╮ 提交于 2019-12-21 16:23:18
问题 +---------+---------+------+-----+---------+----------------+ | 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

st_intersects Vs st_overlaps

六眼飞鱼酱① 提交于 2019-12-21 12:22:36
问题 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? 回答1: From the

Datatable containing SqlGeometry is causing stored procedure execution to fail… Why?

你说的曾经没有我的故事 提交于 2019-12-21 05:33:34
问题 I'm trying to save a series of SqlGeometry values to a SQL Server 2008 database. Basically I have a tabletype in a SQL Server stored procedure which looks like this: CREATE TYPE [dbo].[TableType_Example] AS TABLE ( [SpatialID] [bigint] NOT NULL, [RecordID] [bigint] NOT NULL, [geom] [geometry] NOT NULL ) I then build a datatable in C# and send it like this: public static bool SaveSpatialDataElements(long recordID, List<BOSpatial> featureList) { //Setup features datatable DataTable dtFeatures =

How to perform a vector overlay of two SpatialPolygonsDataFrame objects?

蓝咒 提交于 2019-12-21 04:54:13
问题 I have two GIS layers -- call them Soils and Parcels -- stored as SpatialPolygonsDataFrame s ( SPDF s), and I would like to "overlay" them, in the sense described here. The result of the overlay operation should be a new SPDF in which: The SpatialPolygons component contains polygons formed by the intersection of the two layers. (Think all of the atomic polygons formed by overlaying two mylars on an overhead projector). The data.frame component records the attributes of the Soils and Parcels

How to correct Polygon Ring Orientation using C# Entity Framework 5 DbGeography Spatial Data

佐手、 提交于 2019-12-21 04:39:09
问题 I'm working with the new Entity-Framework 5 using the Spatial data type DbGeography as part of my model for storing in one instance, a POINT and in another instance a POLYGON. When setting the value of my POLYGON all saves with no error however this is only the case if I draw the Polygon on the map in a clockwise order. If I draw the POLGON in an anti-clockwise direction I get an error the the sql level indicating that the data is an invalid geography type. Now after doing my own research

Calculate Minimum Bounding Rectangle Of 2D Shape By Coordinates

空扰寡人 提交于 2019-12-20 23:31:14
问题 I have a solution that uses spatial data to represent a cluster of points on a map. I have the need to used the coordinates that represent the extents of a cluster to find the minimum bounding rectangle that can contain said cluster of points. Does any simple algorithm exist to be able to calculate this or is there any built in functionality in C# to achieve this. I am aware of the NetTopologySuite but am not sure how/if I could use this to achieve the same goal. I have a list of coordinates

SpatialLinesDataFrame: how to calculate the min. distance between a point and a line

一笑奈何 提交于 2019-12-20 14:13:54
问题 I have a SpatialLinesDataFrame with streets and I have a list of GPS coordinates. What I need to do is to get out the 10 closest street names for each individual GPS coordinate. Is there a function/package in R that would calculate the distance between a line and a point for a SpatialLinesDataFrame? I can't see anything that would help in 'sp'. There is a related question: Calculating the distance between polygon and point in R, but I want to find the distance between a line object and a