geospatial

Java double vs BigDecimal for latitude/longitude

雨燕双飞 提交于 2019-12-20 08:59:13
问题 When storing latitudes/longitudes which are typically of the format: 44.087585 (i.e. max 2 numbers before the dot and 6dp) do I need to bother with bigdecimals? 回答1: Using double has enough precision for accurate lat/lon down to inches for 6-7 decimal places. In aviation, if decimal degrees are used, they typically go to at least 7 decimal places. In our NASA simulations, lat/lon data are doubles while all other attitude and altitude are floats. In other words, the 6th decimal place for

How to define a circle for a mongo db schema?

99封情书 提交于 2019-12-20 07:13:26
问题 I have the folowing code to define a schema: var mongoose=require('mongoose'); var Schema=mongoose.Schema; var PostSchema=new Schema({ location:{type:Array,required:false,select:true} }) PostSchema.index({location:'2dsphere'}); module.exports=mongoose.model('Post',PostSchema); I want to make location field to be seen like a circle(ex:location:{loc:[latitude,longitude],radius:radius})..I want to make a query to find circles form my db which are intersecting with a polygon.Thanks for any help :

Oracle code to calculate distance between point/centroids/polygons

风格不统一 提交于 2019-12-20 06:35:48
问题 I've centroids for customer A and customer B. Now I need to calculate distance between customer A and B into miles using centroids. How can I do it in Oracle? Right now, I'm using alteryx "distance" spatial tool for centroid distance calculation but need to convert it into oracle query. Thanks! 回答1: If you have Cartesian coordinates then the approximate distance if given by the Pythagorean theorem as already provided by Matthew. For Lat/Lon values you should use the Oracle build in SDO_GEOM

rasterize ESRI shapefile with holes but FALSE hole slots

半腔热情 提交于 2019-12-20 05:52:40
问题 I have a shapefile (showing different sediment classes in the northsea) read in with readOGR() . It has a lot of " what should be" holes in many polygons, but using rasterize() does eliminate all the holes since they are not marked as TRUE in their hole-slots. Used rasterize(...,fun='first') with no success. Nevertheless, QGIS shows the holes all nicely. Also, over() correctly evaluates the field values, e.g., in a hole, probably taking advantage of the slot "plot order" which is why I came

Efficient Geodesic Nearest Neighbors

纵饮孤独 提交于 2019-12-20 05:25:42
问题 Starting with latitude/longitude data (in radians), I’m trying to efficiently find the nearest n neighbors, ideally with geodesic (WGS-84) distance. Right now I’m using sklearn’s BallTree with haversine distance (KD-Tres only take minkowskian distance), which is nice and fast (3-4 seconds to find nearest 5 neighbors for 1200 locations in 7500 possible matches), but not as accurate as I need. Code: tree = BallTree(possible_matches[['x', 'y']], leaf_size=2, metric='haversine') distances,

sqlite, index for geographical coordinates?

試著忘記壹切 提交于 2019-12-19 11:19:12
问题 I have a SQLite database that contains geographical data. My table is defined like this: CREATE TABLE GEO_OBJECTS (ID VARCHAR(30) PRIMARY KEY NOT NULL, LATITUDE NUMERIC(6,3) NOT NULL, LONGITUDE NUMERIC(6,3) NOT NULL) Next my software (Java) is looking for GEO_OBJECTS using a simple SQL request like this: SELECT * FROM GEO_OBJECTS WHERE latitude <= 123.4 AND latitude >= 26.32 AND longitude <= 12.41 AND longitude >= 6.23; Will it improve the performances if I create an INDEX on latitude and

Sorting MongoDB GeoNear results by something other than distance?

試著忘記壹切 提交于 2019-12-19 09:02:53
问题 I'm developing a PHP application in which we need to retrieve results within a certain boundary, but ordered by the create date of the results, not the distance. I figured MongoDB's geoNear command would be great for this, since it takes care of calculating the distance for each result. However, I was wondering if there was a way to specify sorting by the create_date attribute, rather than distance. Ideally I would create a compound key index of coordinates and create date, and then quickly

Calculate Centroid WITHIN / INSIDE a SpatialPolygon

依然范特西╮ 提交于 2019-12-19 06:44:33
问题 In Software like ArcMap one can create centroids for polygons within a polygon. In cases like the one shown below this is necessary. In R it is possible to calculate centroids of spatial polygons with rgeos::gCentroid() . However there is no way to force the calculation of centroids within the polygon. library(rgdal) library(rgeos) x <- readWKT("POLYGON ((1441727.5096940901130438 6550163.0046194596216083, 1150685.2609429201111197 6669225.7427449300885201, 975398.4520359700545669 6603079

Calculate Centroid WITHIN / INSIDE a SpatialPolygon

我是研究僧i 提交于 2019-12-19 06:44:32
问题 In Software like ArcMap one can create centroids for polygons within a polygon. In cases like the one shown below this is necessary. In R it is possible to calculate centroids of spatial polygons with rgeos::gCentroid() . However there is no way to force the calculation of centroids within the polygon. library(rgdal) library(rgeos) x <- readWKT("POLYGON ((1441727.5096940901130438 6550163.0046194596216083, 1150685.2609429201111197 6669225.7427449300885201, 975398.4520359700545669 6603079

postgres spatial indexing

梦想与她 提交于 2019-12-19 03:59:00
问题 I can't seem to find much documentation on this. What's the simplest way to create a database/table on postgres supporting a query like this SELECT * FROM table WHERE distance(POINT(0,0), table.location) <= 1000m; Where POINT(0,0) and table.location should be latitude/longitude pair, and 1000m is 1000 meters. And how should I go about indexing that table? Thanks. 回答1: PostgreSQL support indexes on expressions and also partial indexes, you can probably mix them. This is just a random guess, I