geospatial

How to plot regions in a country, each shaded by some corresponding value

旧时模样 提交于 2019-12-23 05:04:23
问题 In particular I have a set of distinct regions in India, each with a "marketshare" value. regions <- data.frame(Region=c("TELANGANA", "TAMIL NADU", "JAMMU & KASHMIR"), Marketshare=c(.25, .30, .15)) regions Region Marketshare 1 TELANGANA 0.25 2 TAMIL NADU 0.30 3 JAMMU & KASHMIR 0.15 I can plot India using ggmap real easily using library(ggmap) map <- get_map("India", zoom=6, maptype="toner-lite") ggmap(map) But how can I specifically include the regions in my dataset and shade each of them

R spdep giant weight matrix

此生再无相见时 提交于 2019-12-23 04:51:11
问题 I'm new to spatial statistics, and I'm trying to create a spatial weight matrix for all Census tracts in the US in R. There are around 74000 tracts. Based on US Census Tiger Files, I created a shapefile of all tracts, and then did (using the spdep package): #Create adjacency matrix am = poly2nb(us) is.symmetric.nb(am) This works fine, though am is pretty large. Next: am = nb2mat(am, style="B",zero.policy=T) Which gives me this error: Error: cannot allocate vector of size 40.9 Gb Obviously my

Great Circle distance plus altitude change

流过昼夜 提交于 2019-12-23 04:43:23
问题 How do you exactly compute the distance traveled between two points at different altitudes on a spherical body? If the two points are at the same altitude it's a simple great-circle calculation. But what is the additional term to account for a steady climb or descent precisely? Say we're talking about a spaceplane that steadily climbs up to a great height over a great distance after taking off. Illustration: http://i.imgur.com/nAp1S.png 回答1: The National Geodetic Survey (NGS) (a division of

Coordinates comparison in database

拜拜、爱过 提交于 2019-12-23 04:26:26
问题 I am developing a Spring app that has to search for persons using GPS coordinates. For each in the DB person I have his latitude and his longitude. The client pass a point and a max distance to the server which has to return all the clients around this point in this distance. The problem is that the database contains about 300k persons, so getting all the persons and iterating through this list to chck if they are near the point is really slow. Any idea to speed up this search ? 回答1: The best

mongodb and geospatial schema

為{幸葍}努か 提交于 2019-12-23 03:50:46
问题 im breaking my head with mongo and geospatial, so maybe someone has some idea or solution how to solve this: my object schema is like this sample for geoJSON taken from http://geojson.org/geojson-spec.html. { "name":"name", "geoJSON":{ "type":"FeatureCollection", "features":[ {"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[100,0],[101,0],[101,1],[100,1],[100,0]]]},"properties":{}}, {"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[100,0],[101,0],[101,1],[100,1],

MySQL GeoSpatial function for ST_Distance_Spheroid? Metric used in return Type of GLength?

ぃ、小莉子 提交于 2019-12-23 02:58:20
问题 Is there a ST_Distance_Sphere, ST_Distance_Spheroid equivalent function in MySQL's GeoSpatial Support? If not, any way to emulate this? What is the metric used in return type of GLength (length of the LineString)? The manual for GLength says that GLength() is a nonstandard name. It corresponds to the OpenGIS Length() function. But I couldn't find any Docs for OpenGIS Length(). All I found was for ST_Length are they the same? Also for accuracy do I need to specify the SRID(4326)? How Do I do

Mongo geolocation using $near and 2d index not being accurate

青春壹個敷衍的年華 提交于 2019-12-23 01:37:20
问题 I've written an application that finds local establishments and delivers them via a RESTful API. My stack is: express, express-resource and mongoose. Here is a sample of my model: var PlaceSchema = new mongoose.Schema( { name: { type: String, required: true }, geolocation: { lat: Number, lng: Number }, address: { type: String } } ); PlaceSchema.index({ geolocation: '2d' }); I've checked a few times and my lon/lat values are being correctly stored in the db, so there aren't any data errors.

Why is crop sometimes introducing NAs on a categorical raster?

偶尔善良 提交于 2019-12-22 18:40:18
问题 library(raster) r <- raster('glc2000_v1_1') # http://forobs.jrc.ec.europa.eu/products/glc2000/products/glc2000_v1_1_Grid.zip extent(r) # class : Extent # xmin : -180.0045 # xmax : 179.9955 # ymin : -56.01339 # ymax : 89.99554 ext <- extent(-69,-63,-3,3) r1 <- crop(r,ext) #Warning message: #In .getRat(x, ratvalues, ratnames, rattypes) : NAs introduced by coercion If I try to crop a smaller area, it works fine. ext <- extent(-68,-64,-2,2) r1 <- crop(r,ext) # works fine This error is preventing

Save a ggplot2 coord_map() chart in shapefile

守給你的承諾、 提交于 2019-12-22 17:05:25
问题 i need to export a contour map in CARTO (aka cartodb), so i'm trying to save this stat2density chart in a geodata file format like shapefile or geojson. I'm able to save it in SVG with ggsave, but would be very helpful to convert it in a spdf or sf oblejct. library(ggplot2) library(ggmap) data("crime") crime<- head(crime,1000) gg <- ggplot(aes(x = lon, y = lat), data=crime) + stat_density2d(aes(alpha=..level.., color=..level.., fill=..level..),geom='polygon', bins = 10, size=0.5) + scale

Removing data outside country map boundary in R

给你一囗甜甜゛ 提交于 2019-12-22 10:27:39
问题 I know this is simple but could get this working. I want to remove the excess data points on the map below. How do i do it? Below code gave me the results. ggplot() + geom_polygon(data = rwa2, aes(x = long, y = lat, group= group), colour = "black", size = 0.5, fill = "white") + geom_tile(data = df, aes(x = Lon, y = Lat, z = z, fill = z), alpha = 0.8) + ggtitle("State Data") + xlab("Longitude") + ylab("Latitude") + scale_fill_distiller(type = "div", palette = "Spectral")+ theme_bw() + theme