geospatial

Determine if Lat/Lng in Bounds

时光总嘲笑我的痴心妄想 提交于 2020-04-08 05:00:15
问题 I'm interested in determining if a lat/lng location is within the bounds and looking for recommendations on a algorithm. (javascript or php) Here is what I have so far: var lat = somelat; var lng = somelng; if (bounds.southWest.lat < lat && lat < bounds.northEast.lat && bounds.southWest.lng < lng && lng < bounds.northEast.lng) { 'lat and lng in bounds } will this work? thanks 回答1: The simple comparison in your post will work for coordinates in the US. However, if you want a solution that's

How to keep the only intersection of the spatial features & remove everything outside of a boundary?

最后都变了- 提交于 2020-03-18 06:36:15
问题 I am trying to get rid of the spatial geometry that falls outside of the shapefile boundary I read. Is it possible to do this without manual software like Photoshop? Or me manually removing the tracts which span outside of the city's boundries. For example, I took out 14 tracts, this is there result: I have provided all of the subset of the data and the key to test it yourself. Code script is below, and the dataset is https://github.com/THsTestingGround/SO_geoSpatial_crop_Quest. I have done

Reading a binary map file in r

故事扮演 提交于 2020-02-29 05:49:10
问题 I am trying to read a binary file in R containing a simple 2D array of 360x180 values. For reference, the binary file can be found here: http://transcom.project.asu.edu/download/transcom03/smoothmap.fix.2.bin Here is what the readme for this .bin says: The file 'smoothmap.fix.2.bin' contains a single real, binary array dimensioned 360 x 180. The array contains the numbers 1 through 22, denoting each of the 22 basis functions in the TransCom 3 experiment. This file was written on an SGI Origin

Use sf polygon object as window in spatstat

六眼飞鱼酱① 提交于 2020-02-25 13:16:39
问题 Hello all potential helpers, I have a SpatialPolygonDataFrame object obtained from the tigris package and I would like to use it as a polygonal window in the creation of a ppp object. Here is what I tried: # Needed packages library(spatstat) library(sf) # Download geospatial data for Lee county in Alabama (home of the great Auburn University by the way!) county <- tigris::county_subdivisions(state = "Alabama", county = "Lee") # The polygon of Lee county is subdivided, so I convert it to a

MongoDb C# GeoNear Query Construction

▼魔方 西西 提交于 2020-02-13 04:47:33
问题 How do I query MongoDB for nearby geographic points using the C# driver and the GeoNear method? The following returns points with an incorrect Distance value: var results = myCollection.GeoNear( Query.GT("ExpiresOn", now), // only recent values latitude, longitude, 20 ); I suspect I should be telling Mongo to query on the double[] Location field, but I don't know the query syntax. 回答1: Found the answer via this and this: var earthRadius = 6378.0; // km var rangeInKm = 3000.0; // km

MongoDb C# GeoNear Query Construction

烂漫一生 提交于 2020-02-13 04:47:15
问题 How do I query MongoDB for nearby geographic points using the C# driver and the GeoNear method? The following returns points with an incorrect Distance value: var results = myCollection.GeoNear( Query.GT("ExpiresOn", now), // only recent values latitude, longitude, 20 ); I suspect I should be telling Mongo to query on the double[] Location field, but I don't know the query syntax. 回答1: Found the answer via this and this: var earthRadius = 6378.0; // km var rangeInKm = 3000.0; // km

Spatial Indexes with DocumentDB

北城以北 提交于 2020-01-25 01:49:20
问题 I’m trying to do a spatial query against DocumentDB that looks like this: SELECT * FROM root r WHERE ST_WITHIN({'type':'Point','coordinates':[-122.02625, 37.4718]}, r.boundingBox) to match a document that looks like this in the collection: { "userId": "747941cfb829", "id": "747941cfb829_1453640096710", "boundingBox": { "type": "Polygon", "coordinates": [ [-122.0263, 37.9718], [-122.0262, 37.9718], [-122.0262, 36.9718], [-122.0263, 36.9718], [-122.0263, 37.9718] ] }, "distance": 0, "duration":

Small multiple maps with geom_sf at the same spatial scale

允我心安 提交于 2020-01-24 10:46:05
问题 I would like to plot a figure with small multiple maps using ggplot2::geom_sf . The challenge here is how to do this keeping all maps centered in the image and at the same spatial scale. Here is the problem (data for reproducible example below): A simple map using facet_wrap put all polygons at the same spatial scale, but they are not centered. ggplot(states6) + geom_sf() + facet_wrap(~name_state) Here is a solution from this SO question that uses cowplot . In this case, polygons are centered

How do I create an Accessor for a POINT data column in a Laravel 4 model?

时间秒杀一切 提交于 2020-01-23 11:58:18
问题 I've got a user_sessions table that has a column named "geo_location", it's a POINT column that stores the latitude and longitude values for a user's current location, or NULL if it's not available. When I create a Model in Laravel that binds to that table it only works when the geo_location field is hidden completely. Otherwise it throws a JSON error because it's not properly querying for the separate X and Y values in the geo_location column. Is there a way that I can create an Accessor in

Scipy: how to convert KD-Tree distance from query to kilometers (Python/Pandas)

只愿长相守 提交于 2020-01-23 00:39:12
问题 This post builds upon this one. I got a Pandas dataframe containing cities with their geo-coordinates (geodetic) as longitude and latitude. import pandas as pd df = pd.DataFrame([{'city':"Berlin", 'lat':52.5243700, 'lng':13.4105300}, {'city':"Potsdam", 'lat':52.3988600, 'lng':13.0656600}, {'city':"Hamburg", 'lat':53.5753200, 'lng':10.0153400}]); For each city I'm trying to find two other cities that are closest. Therefore I tried the scipy.spatial.KDTree. To do so, I had to convert the