FAQ Database Discussion Community

Waypoint matching query for MongoDB or Elasticsearch

mongodb,elasticsearch,mongodb-query,geospatial
We have collection as follows. Each document represent a trip of driver, loc property contains way-points, time property contains time corresponding to way-points. For example, in Trip A, Driver would be at GeoLocation tripA.loc.coordinates[0] at the time tripA.time[0] { tripId : "Trip A", time : [ "2015-03-08T04:47:43.589Z", "2015-03-08T04:48:43.589Z", "2015-03-08T04:49:43.589Z", "2015-03-08T04:50:43.589Z",...

Can I store circle and polygon within the same spatially indexed column in postgis?

geospatial,postgis,postgresql-9.3,spatial-query,spatial-index
According to their documentation the spatial objects can be of the following POINT(0 0) LINESTRING(0 0,1 1,1 2) POLYGON((0 0,4 0,4 4,0 4,0 0),(1 1, 2 1, 2 2, 1 2,1 1)) MULTIPOINT(0 0,1 2) MULTILINESTRING((0 0,1 1,1 2),(2 3,3 2,5 4)) MULTIPOLYGON(((0 0,4 0,4 4,0 4,0 0),(1 1,2 1,2...

R: ggplot2 fill polygons in shapefile by coords

r,ggplot2,geospatial
So i have shapefile (named POWIATY at the bottom of the page). I want to fill the specific polygons by the coords I have. Let's say, I want to fill whole region in: lat:52.599427 lon:20.7572137 I know how to set point coords on the map but how to fill whole...

Polygon insertion issue (due to SRID) on Postgres

postgresql,geolocation,geospatial,postgis,sequelize.js
I'm having trouble inserting a polygon into my table structure. I'm relatively new to PostGIS, so I may be making a pretty amateur mistake on this. My table is setup as "Regions" and I'm adding a column for my geometry: "SELECT AddGeometryColumn(" + "'public', 'Regions', 'geom', 4326, 'POLYGON', 2" +...

GDAL show me a possible path error

python,django,postgresql,geospatial,spatial
I installed PostGIS on my Open SUSE distribution to make preparations for a project that should include a spatial database, so i heard to do that i need PostGIS libs for "spatial capabilities". I wanna deploy an open source app that was done in django and I'm getting a: OSError:...

spatial clustering in R (simple example)

r,geospatial,spatial,hierarchical-clustering
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...

mapping all of Latin America with rworldmap

r,maps,geospatial,spatial
I am trying to plot some data for different countries in Latin America using the rworldmaps package. When including mapRegion='latin america', Mexico is cut off...is there any way to include Mexico other than by overriding using ylim and xlim? Thanks. library(rworldmap) df <- NULL df$country <- c("Brazil","Mexico","Argentina") df$code<-c("BRA", "MEX", "ARG")...

How to add a SpatialPolygons to a bubble plot in R

r,geospatial,sp
I would like to use the function bubble from the packge sp to plot data and I would like to add a SpatialPolygons layer. I can easily plot the data using spplot but for some reason it doesn't work with bubble. For example: library(sp) # Create SpatialPolygons Sr1 <- Polygon(cbind(c(2,4,4,1,2),c(2,3,5,4,2)))...

How to check if a polygon contains another polygon in OL3?

algorithm,openlayers,geospatial,openlayers-3
Is there any possibility to check if a polygon is contained in another polygon in OL3? I noticed there is a couple of methods in ol.extent e.g. ol.extent.containsExtent(extent1, extent2). But this checks only the extents and not the entire polygon. So in some cases I get "true" although the polygon...

Finding the distance of a coords from the begning of a route in Python

python,geospatial,shapely
I have a list of coordinates (lat/lon) representing a route. Given a certain radius and another coordinate I need to check if the coord is in the route (within the given radius from any point) and it's distance from the begning of the route. I looked at shapely and it...

Use of Planet.osm with osmDroid for offline maps

android,geolocation,geospatial,openstreetmap,osmdroid
does anyone know if it is possible to build an Android application using osmDroid that makes use of Planet.osm stored on an SD card? for example, you would store Planet.osm on a large SD card that has been put in a phone. The application loaded on the phone would then...

How to search documents with MongoDB geospatial queries within nearest cities in country?

mongodb,geolocation,geospatial
Let's say user finds documents with in Wellington New Zealand and provide coordinates of Wellington city: lat: -41.2864603, lng: 174.77623600000004. But if there are no documents within this city I need to search documents within nearest cities within New Zealand country. How could I find documents within country?...

Finding nearest grid value in spatial dataframe in R

r,geospatial,raster,gstat
I am learning about spatial dataframes. I have created a simple example that uses inverse distance weighting (IDW) to interpolate values across a grid, based on an initial set of points. I would now like to obtain the interpolated value for each of the initial points. I would presume that...

Spring Data- MongoDB geoNear not getting distributed in replicaset

spring,mongodb,geospatial
We are using a replica-set of MongoDB with 1 Primary, 1 Secondary and 1 Arbiter. At our java application, we are using Spring-data-mongodb to interact with MongoDB. A key use case in our application involves using an aggregation pipeline with geoNear query with distance sorting which is something like this...

Sorting users by distance in mysql using st_distance

php,mysql,geolocation,geospatial
I've done a bit of reading on this but there's hardly any information on doing it using points and the st_distance function in mysql. I suppose this makes sense since according to http://bugs.mysql.com/bug.php?id=70494 it wasn't even documented until halfway through last year. Almost every solution I've seen instead uses separate...

Is it possible to use a document field as radius with distance function in Google search API?

I have stored circular approximations of trajectory data as documents via the Google Search API. That means I am calculating the circumcircle around an arbitrary trajectory and storing the middle point as geo point field with longitude and latitude into the document. In addition to that I save the radius...

how to get the distance or radian between two point on the earth with lng and lat?

geolocation,geometry,geospatial
how to get the distance or radian between two point on the earth with lng and lat?

SQL Server Spatial Indexes Setup

sql-server,geospatial,spatial-index
I currently have two tables cities and listings, both have a field called Position and that is a spatial field. My question is have i set up my indexes correctly or should I add/remove some? For cities I do not show them on a map, I only use one query...

Using ensureIndex for locations in publications in Meteor

javascript,mongodb,meteor,geospatial
I am currently trying to only pull collections that are near the user. I have been able to successfully do this on the client with some of my other collections, but am struggling to accomplish it in publications. I have the following code in my server/index.js: Events._ensureIndex({'loc.coordinates':'2dsphere'}); And the following...

Using geospatial commands in rethinkdb with changefeed

geospatial,rethinkdb
right now I have a little problem: I want to use geospatial commands (like getIntersecting) together with the changefeed feature of rethinkdb but I always get: RqlRuntimeError: Cannot call changes on an eager stream in: r.db("Test").table("Message").getIntersecting(r.circle([-117.220406,32.719464], 10, {unit: 'mi'}), {index: 'loc'})).changes() the big question is: Can I use getIntersecting with...

Geohash not generated in Elastic search

elasticsearch,geolocation,geospatial,geohashing
I have created an index as follows: POST /cabtrails { "settings" : { "number_of_shards" : 3, "number_of_replicas" : 1 }, "mappings" : { "cabtrail" :{ "properties" : { "location": { "type": "geo_point", "geohash_prefix": true, "geohash_precision": "5m" }, "capture_time": { "type" : "long" }, "client_id": { "type" : "long" } }...

MBRContains distance from location help MySQL

mysql,performance,optimization,geospatial
Ok so I am new to the MBRContains method and having trouble getting a method to work. Basically I am just trying to filter listings dependent on distance away from an input location. I heard this method is quicker than just doing the complex math calculations. Please correct me if...

Using MySQL 'POINT' and PHP to insert Latitude and Longitude points through a form

php,mysql,geospatial
I'm making a web based application that allows users to create routes based on their input. The user adds waypoints to google maps and takes the latitude and longitude points and copies it into a table on the website that then sends the data to a MySQL database using PHP....

Error : increasing 'x' and 'y' values expected in persp {fields}

r,plot,order,geospatial
I have 500 points in space with lat, lng as : lng=runif(100,1,4) lat=runif(100,40,40.1) Let's say that we have there (density) as z=rnorm(1000) I've tried to plot 3d surface using persp persp(lng,lat,z) But I have this error : Error : increasing 'x' and 'y' values expected I sorted x and y...

How to convert a dataframe into a gstat object in R? Specifically a gstatVariogram

r,type-conversion,geospatial,gstat,covariogram
I'd like to create a variogram fit from some semivariance data in R. I realize that a variogram fit requires an object generated by vgm, and raw.vgm gneerated by variogram, for example: x = seq(0,300,by=300/100) y = seq(0,0.9,by=(0.9/100)) Z = seq(0.0,10.0,by=(10/100)) raw.dat = data.frame(x=x,y=y,Z=Z) g <- gstat(formula=Z~1, locations=~x+y, data=raw.dat) raw.vgm...

MemSQL geospatial union of polygons

union,geospatial,memsql
Will the new MemSQL version be able to calculate the union of polygons? For example calcuate the border of two adjacent or even intercepting polygons? +----+ | | | +-+--+ +--+-+ | | | +----+ to +----+ | | | +--+ +--+ | | | +----+ ...

How to compute greatest distance between polygon centroid and edge

r,geospatial,spatial,sp
I have a SpatialPolygons(DataFrame) object, e.g. SpP library(sp) Sr1 = Polygon(cbind(c(2,4,4,1,2),c(2,3,5,4,2))) Sr2 = Polygon(cbind(c(5,4,2,5),c(2,3,2,2))) Sr3 = Polygon(cbind(c(4,4,5,10,4),c(5,3,2,5,5))) Sr4 = Polygon(cbind(c(5,6,6,5,5),c(4,4,3,3,4)), hole = TRUE) Srs1 = Polygons(list(Sr1), "s1") Srs2 = Polygons(list(Sr2), "s2") Srs3 = Polygons(list(Sr3, Sr4), "s3/4") SpP = SpatialPolygons(list(Srs1,Srs2,Srs3), 1:3) I would like to, for each polygon, calculate the greatest...

Bottom-up parsing for sqlite R*TREE

sqlite,data-structures,geolocation,geospatial,r-tree
I'm trying to implement an R-Tree for geo-spatial search on an embedded system. The R-tree will be stored in an SD card. I came across the sqlite implementation of an R*tree. I would like to know if the following is possible before I delve into it further - 1. Bottom-up...

Elasticsearch with geo location

mongodb,elasticsearch,geospatial
Little Background. Our software uses MongoDB to save data. We have created text index and geo location index on it. Problem is query using both text and goe location is not supported in MongoDB. Our requirement is to search using natural language, restricting search to particular geo location and sorting...

Project array content with mongodb

arrays,mongodb,mongoose,coordinates,geospatial
My problem is that when I'm using MongoDB 2D index for coordinates everything works just fine but the JSON output is not what I desire. var schema=new Schema({ location:{ type:[Number], // [<longitude>, <latitude>] index:'2d', required:false } }); **desired output** { "_id":"xxx", "longitude":18.056974411010742, "latitude":54.31120601701069, } **what i get** { "_id":"xxx", "location":[18.056974411010742,54.31120601701069]...

Getting geodjango query to return distance as an attribute?

python,django,geospatial,geodjango
Is there a way to get a query to return the distance from the point for each location? Right now I have Location.objects.filter(geometry__distance_lte=(pnt, D(mi=20))) but the rows don't have a distance attribute. How can I get the distance from pnt for each row that is returned?

Model.solr_search not working for geospatial filter

ruby-on-rails-4,solr,geospatial,sunspot-solr
I have configured sunspot-2.1.1. Problem I want to search All products within 20 miles radius and below is my code to do that for Product model Product.search do fulltext(params[:search][:keyword]) order_by_geodist(:location, current_user.lat, current_user.lng) with(:location).in_radius(current_user.lat, current_user.lng, mile_to_km) paginate page: params[:page], per_page: GlobalConstant::SEARCH_RESULT_PER_PAGE end NOTE: above code is working properly in development environment...

How to transfer longlat format DEM data to utm

r,geospatial,rgdal
I downloaded a digital elevation data set. The file is '.tif' format. I have loaded in R. But when I try to transform the coordinate reference system from long/latitude to local UTM, problems occur. The code and errors are presented as below. dem=raster('srtm_58_04.tif') proj4string(dem)="+proj=longlat +ellps=GRS80 +no_defs" myproj="+proj=utm +zone=48 +north +datum=WGS84...

CKAN - Vector Storer Extension error

python,geospatial,ckan
I have installed CKAN on a Ubuntu 12.04 64bit system and everything was fine. I also installed correctly these extensions: geojson_preview wms_preview spatial_metadata spatial_query disqus pdf_preview spatialUI googleanalytics archiver contact Now, I wanted to add vectorstorer extension but it is appearing an error that I don't have any idea how...

Count number of buffers that touch a (polygon) feature

buffer,polygon,geospatial,spatial,arcgis
I'm facing the following task in ArcGIS - I'm using ArcMap 10.2 I have a polygon shapefile with counties of (say) a state in US. From this shapefile, I create a layer which marks all counties in which there is at least 1 city of more than 50000 inhabitants (I...

guide/information on building an offline mapping Android application using nutiteq

android,dictionary,geolocation,geospatial,nutiteq
Does anyone have or know of any guides/tutorials/information on how to build an offline mapping Android application using nutiteq?

Failure when searching for all polygons near a point using mongoose/mongodb

node.js,mongodb,mongoose,geospatial,geojson
I am trying to search for any GeoJSON polygon that is with x number of kilometers from a point ordered by distance from the point. It's important that it is a GeoJSON polygon and not a GeoJSON point. I have the following but I get an error: 'Unable to execute...

Elasticsearch geospatial search, problems with index setup

elasticsearch,geospatial
I'm trying to search for documents previously added to an index, which has been configured to allow geospatial queries (or so I think). My elasticsearch instance is hosted on qbox.io. This is the code I wrote to create an index from the command line curl -XPOST username:[email protected]/events -d '{ "settings"...

C# SQL Geometry Error: Invalid operator for data type. Operator equals equal to, type equals geometry

c#,asp.net,sql-server,geospatial
Using C# and LOCAL SQL SERVER Making an SQL call which is: string cmd2 = "SELECT Circle_ID FROM Circle WHERE Center_Point = geometry::STGeomFromText('POINT("; cmd2 += center_lat; cmd2 += " "; cmd2 += center_lng; cmd2 += ")',0)"; and I receive the error: Invalid operator for data type. Operator equals equal to,...

MongoDB geospatial difference between $near and$within

mongodb,geospatial
What is the difference between $near and$within? db.geodata.find({ "loc" : { "$within" : { "$center" : [ [ 12.91365 , 77.59395] , 4]}}}).limit(10); db.geodata.find({ "loc" : { "$near" : [ 12.91365 , 77.59395] , "$maxDistance" : 4}}).limit(10); Can anyone explain in detail? ...

Check if location is within a certain distance of a set of other locations using R

r,match,geospatial,distance,latitude-longitude
I've been trying to solve this problem for a while now, but I can't seem to wrap my head around it. I am still new to R and a first time poster here. I tried to follow the rules as much as possible, but please let me know if I...

Difference in $geoWithin and$geoIntersects operators?

mongodb,geospatial,mongo-java
What is the difference in $geoWithin and$geoIntersects operators in mongoDB? If I am looking for coordinates (using default coordinate reference system), $geoWithin and$geoIntersects will return the same result. Please correct me if I am wrong. Any simple use case for understanding the difference would be appreciated. ...

Wraping of equispaced point set in a given direction

java,r,algorithm,geospatial,graph-algorithm
Let us consider a 2-D (latitude, longitude) point set. The points in the set are equispaced (approx.) with mutual distance 0.1 degree \times 0.1 degree . Each point in the set is the centre of a square grid of side length 0.1 degree (i.e., intersect point of two diagonals of...

Extract GPS information to “steady” and “Moving”

android,r,gps,geolocation,geospatial
I have questions related with GPS data. I have data looks like The question is, I want to extract information from that data to the value3, I want to fill value3 with "steady" and "moving". steady and moving based on values from latitude and longitude, but I also still confused...

Find Mongoid geospacial circles that contain a point

mongodb,mongoid,geospatial
I have Mongoid documents that represent services offered by local merchants. Each has one or more locations (lat/lng point) with a service area (radius). Given a customer location (lat/lng point), how can I find all the documents where the customer location falls within the service area? class Service include Mongoid::Document...