I need to find out in what country given GPS coordinates are, on a device that has no Internet access (e.g. this, but without the easy on-line solution). Having no experience with GIS, I guess I'd need some kind of module that would statically store shapes of countries and match current location against them.
I'd therefore like to ask what kind of tools would be best for this, and what is the best way to obtain the country data. I'm using Python on an embedded Linux box.
There's a shape file here with all of the country borders. You can then use OGR or something like this to access the data.
You might have a look at the GeoDjango documentation even if you aren't making a web application. The tutorial covers importing the world boundaries shapefile.
Have you seen https://github.com/krisrak/ios-offline-reverse-geocode-country/?
all offline ... no need for any APIs super fast .
accuracy not guaranteed !!
You would need a map with the boundaries of each country. Then, given a coordinate, you would need to calculate in which boundary the point fell. Of course, the two challenges there are collecting the data and representing it, and doing the math to find where a point falls.
Does anyone know how Yahoo does it? Could you possibly port their approach locally?
Related
I am trying to transform a solid created in a CAD program (saved in a STEP file) into a CSG object constructed with simple primitives.
I am not very familiar with the different geometry file formats but as far as I understand it should be possible to do, at least with some simple solids, since the information about the face shapes etc. is stored in a STEP file. I have found this issue https://github.com/tpaviot/pythonocc-core/issues/470 which proves you can extract some of this information. However I am not sure this is enough to achieve my goal.
As an example, I would like to go from the following CAD design / STEP file:
to a CSG description which should describe the geometry as a big cylinder with three smaller cylinders as subtractions.
Ideally I would use a python library for this purpose, perhaps this library is a good candidate.
However I am afraid this isn't theoretically possible since I am not finding much information online.
As a last resort I could just mesh the solid and generate a CSG description using a tessellated solid, but I want to use simple primitives such as boxes or cylinders whenever possible.
I would love to know if this is possible to do and if so, I would love some resources to read about this. Thanks!
After searching around it appears that many people already have the lat/long data of the geographic points of interest they are interested in reverse-geocoding.
In my scenario I know a starting location and would like to find all points of interest (mainly residences within a neighborhood) that lie within a specific radius (say, 1 mile).
The first step is simply specifying a starting point and a radius to search within but I can't seem to figure out how to do this using the the Google Geocoding API (I'm not tied to Google... just figured I'd start there).
I am currently working in python (geopy and pygeocoder) but will eventually port it to iOS.
Any pointers would be much appreciated.
I think you may be going down the wrong path with the Google Geocoding API. What you probably want to use is Google Places API.
One (simplified) way to think about is geocoding takes in a point and returns a point. What it sounds like you want to do is pass in an area, defined by a central point and a radius, and receive a collection of points contained within that area. It looks like the Google Places API can help you with that.
Have you considered using OpenStreetMap for your task? With the help of the Overpass API you can query for all data within a given bounding box. For example this query returns all data within the current view. It uses the overpass turbo for visualization and the Overpass API only in the background but of course you can also use the Overpass API directly for returning raw data as XML or JSON.
You can even specify which exact data categories to return, for example all shops selling clothes. Take a look at commonly used tags and the Overpass API language guide for more information.
In case you haven't already, check out Radar Search & Nearby Search
https://developers.google.com/places/documentation/search#RadarSearchRequests
I'm interested in using python to make diagrams representing the size of values based on the size of squares (and optionally their colour). Basically I'm looking for a way to make overviews of a bunch of values like the good old program windirstat does with hard-drive usage (it basically makes a big square representing your harddrive and then smaller squares making up the area inside of it representing different programs, the bigger the square the larger the file, colour indicates the type of file). I'm fairly familiar with matplotlib, and I don't think it's possible to do something like this with it. Is there any other python package that would help? Any suggestions for something more low level if it's not? I guess I could do it manually if I could find a way to draw the boxes programatically (I don't really care about the format, but the option to export SVG as well as PNG would be nice).
Ultimately, it would be nice to have it be interactive like windirstat is, where if you were to hover over a particular square you get more information on it, and if you clicked on it maybe you'd go in and see the makeup of that particular square. I'm only familiar with wxpython for GUI stuff, not sure if it could be used for something like this. For now I'd be happy with just outputting them though.
Thanks a lot!
Alex
Edit:
Thanks guys, both your answers helped a lot.
You're looking for Treemapping algorithms. Once implemented, you can transform the output (which should be rectangles) into plotting commands to anything that can draw layered rectangles.
Edit:
More links and information:
If you don't mind reading papers, the browser-based d3 library provides for 'squarified' treemaps (js implementation). They reference this paper by Bruls, Huizing, and van Wijk. (This is also citation 3 on the wikipedia article)
I'd search on the algorithms listed on the linked Wikipedia article. For instance, they also link to this article, which describes an algorithm for "mixed treemaps". The paper also includes some interesting portions at the end describing transformations into other-than-rectangular shapes.
Squarified certainly appears to be the most common variety around. The above links should give you enough to work towards a solution or, even, directly port the d3 implementation. However, the cost of grokking d3's model (which is something like a declarative form of jQuery) may be somewhat high. At first glance, though, the implementation appears relatively straightforward.
Squaremap does this. I haven't used it (I only know it from RunSnakeRun) and its documentation is severely lacking, but it seems to work.
I have a list of 50000 latitude/longitude pairs and want to plot them on a map. I tried http://gsl-nagoya-u.net/appendix/software/worldmap/. It works but it seems to ignore the data after a certain point (less than 100). What else can I use to generate a static image? I'd rather not use Javascript.
Perl has GD::Map in CPAN which looks about right. I haven't used it myself to say for sure, but its the closest thing I could find based on your requirements.
You can use the google maps static image api, it has a 1000 images/day limit, but you could get it in 5 50 days. Script the creation of the links and save the resulting image.
Edit: Looks like I misread your total number of pairs. 50 days is quite a long time, perhaps there is some way to avoid this, otherwise maybe this won't be preferred.
You could look at MapServer. It's more of a complete GIS platform, so if you only need to do this one time, it is a bit of an overkill.
Someone else would have to tell you where to get baselayers, but you can render reasonable maps with QGIS.
After searching SO and multiple articles I haven't found a solution to my problem.
What I am trying to achieve is to load 20,000 markers on Google Maps.
R-Tree seems like a good approach but it's only helpful when searching for points within the visible part of the map. When the map is zoomed out it will return all of the points and...crash the browser.
There is also the problem with dragging the map and at the end of dragging re-running the query.
I would like to know how I can use R-Tree and be able to achieve the all of the above.
As noted, R-Tree won't help you when you're looking at a zoomed-out view. This problem is often addressed by marker clustering, because showing 20,000 points in a browser window isn't that useful.
Marker Manager is an open source javascript library which addresses this, but there are others.
With a very great number of markers, you may need to look at server-side clustering, (where R-Tree may come in handy!). Here is one discussion of it, and its google cache because link is dead at time of writing.
If you don't want to bother with clustering, then just terminate your marker list at a preset number, maybe a few hundred (which you can determine by usability testing), and display some indication that there are more available as you zoom in