Hot answers tagged

40

All we need to create an interactive Google Map in the notebook is access to the individual tiles - and there is a relatively simple naming scheme for those tiles. I actually typed up a description of this naming scheme a few years ago and posted it here: http://facstaff.unca.edu/mcmcclur/GoogleMaps/Projections/GoogleCoords.html The examples on that page ...


24

In the example code, CountryData[#, "AntarcticNations"] is a built in predicate that returns True or False. You need something similar for your countries. Perhaps, myCountries={ "Germany","Hungary","Mexico","Austria", "Bosnia","Turkey","SouthKorea","China"}; Graphics[{If[MemberQ[myCountries,#],Orange,LightBrown], ...


24

In the comments mfvonh correctly points out that the Wikimapia's URL in my question is a user interface URL, not a tile server URL. The tile server link template is documented in a message which appears when one sends incorrect request to the tile server: From the above it is clear that the StringTemplate should be as follows: ...


23

Thanks to Simon Woods' advises it should now be correct. Taking the OP's informations: loc = {46.72, 25.59};(*CityData["Gheorgheni","Coordinates"]*); dist = 4*10^6;(*distance in m*) bounds = Table[GeoDestination[loc, {dist, i}][[1]], {i, 0, 360, 1}]; Graphics[{EdgeForm@Thin, Red, Polygon[Reverse /@ bounds], Opacity@.33, EdgeForm[Thin], ...


21

To long for a comment, but here's one approach, using information readily available in the docs and on this site: First, make a map that wraps a globe changing the Geoprojection to something a bit more useful. img = With[{Δ = 30}, Row[Table[ GeoGraphics[GeoBackground -> GeoStyling["ReliefMap"], GeoRange -> {{-90, 90}, {λ, λ + Δ}}, ...


20

Well I do not have your data, so I'll just show things I have. I'll go with India, it has nice cities layout. You can upgrade for your data yourself. If you know only locations of cities, but not their population, then data = DeleteCases[ Reverse[CityData[#, "Coordinates"]] & /@ CityData[{All, "India"}], Missing["NotAvailable"]]; ...


19

Due to the limitations on the accuracy of SmoothKernelDistribution (mentioned by Murta) upon which SmoothDensityHistogram is based, I prefer to work with the more exact KernelMixtureDistribution. I will use the same data as Vitaliy here. data = DeleteCases[ Reverse[CityData[#, "Coordinates"]] & /@ CityData[{All, "India"}], ...


18

You can use your ContourPlot, you just need to wrap coordinates with GeoPosition, note that you have to flip order. (if x is longitude and y is latitude, because GeoPosition assumes first is latitude and so on.) cp is Graphics[GraphicsComplex[coordinates, primitives]...], it is convenient to use this form. We can apply GeoPosition in one place and reduce ...


18

Here is a solution I can think of. Idea is to take the FullPolygon of a given country and then triangulate the region. Once that is done take the underlying Graph and do a FindShortestPath. Result will not be too bad. fullPoly = CountryData["Vietnam", "FullPolygon"]; pts = Flatten[fullPoly[[1, 1]], 1]; line = Polygon[Range[##]] & @@@ Partition[{1}~Join~ ...


17

I separated this project into two parts. The first is to compute the coordinates of the Geohash location. (*Grab the user's geographical location. The location is based on IP address, so it may not be completely accurate. It's usually good enough to get your graticute. You can replace home with with known coordinates in the form {hx, hy} if you like.*) home ...


17

Please see the Utility function section for a concise summary. An arbitrary density plot for the example: den = DensityPlot[Sin[x] Sin[y], {x, -180, 180}, {y, -90, 90}] : Extract the graphics primitives from the density plot: prim = First @ Cases[den, Graphics[a_, ___] :> a, {0, -1}, 1]; Plot them directly with GeoGraphics while setting the ...


15

As comments have stated, in most cases FindGeoLocation (and in turn other functions based on your geographical localization) use a so-called GeoIP service (similar to, e.g., this one) to determine to some extent your localization. This can be confirmed by using Trace on FindGeoLocation, which shows that Mathematica calls home to a Wolfram server for this ...


15

I guess you're hoping to take data produced by Mathematica via commands like CountryData and CityData and display that data on a map of some type. From your question, it's honestly not totally clear if you'd prefer an in notebook solution or a completely separate Google Map but both are possible. A static map in notebook In order to display your points as ...


15

Using the new geographic tools in Mathematica 10: GeoGraphics[ GeoCircle[ GeoPosition[Entity["City", {"Gheorgheni", "Harghita", "Romania"}] ], Quantity[4000, "km"] ], GeoBackground -> "StreetMap", (* To get country labels *) ImageSize -> 800 ] WRI posted another example on Twitter. There is another tool called GeoIdentify that ...


15

I take a screenshot of your image and assign it to the image variable. In[2]:= ImageDimensions[image] Out[2]= {1326, 1150} This computes the positions of the lines in your image: In[3]:= lines = ImageLines[Binarize[ColorDistance[image, Gray], {0, .4}]] Out[3]= {{{0., 638.044}, {1326., 638.044}}, {{0., 132.694}, {1326., 132.694}}, {{0., 891.219}, {1326., ...


14

It is version 10.0 specific bug. Please upgrade to a more recent version Version 10.0.0: Version 10.1 and above: Tested on Linux. It seems that other OS have the same behavior. One can extract proper options from recent version and put them to 10.0.0: GeoGraphics[Polygon@Entity["Country", "Russia"], GeoProjection -> {"LambertAzimuthal", ...


13

Here's just a different suggestion. Playing around with the parameters can yield very different results, so it's encouraged. I'm using the same data as Vitaliy: data = DeleteCases[Reverse[CityData[#, "Coordinates"]] & /@ CityData[{All, "India"}], Missing["NotAvailable"]]; outline = ColorNegate@Graphics[CountryData["India", "Polygon"]]; My solution ...


13

There is no built in option, however for the US it's very easy because the coordinates of the state borderlines are all over the Internet. This led me to one such data set. I'll include how I cleaned it up, like this: data = Import["http://econym.org.uk/gmap/states.xml"]; name[{"name" -> n_, ___}] := n coordinates[XMLElement["point", {"lat" -> lat_, ...


13

There is an example of what I think you are trying to do at the end of WeatherData help page, but its a little hard to read. However - here's what I think you want. (* Function to Get a list consisting of {CityName, Temp, Co-ords} given a Countries weather station, note we get the 1st nearest weather station to the city *) weatherdata[cityname_] := ...


13

The polygon of interest is state = Entity["AdministrativeDivision", {"Illinois", "UnitedStates"}]; (polygon = state["Polygon"]) // Short (* Polygon[GeoPosition[{{{36.9821, -89.1329}, <<187>> ,{36.9821, -89.1329}}}]] *) however that expression is not a valid region RegionQ[polygon] (* False *) because the argument of Polygon[] is not a ...


12

The main problem here is that you need to include a VertexTextureCoordinates (VTC) in the Polygon for a texture to be applied. However, the rest of the problem is not as simple as it seems. Here's the output of my approach. Below it, I discuss texturing several polygons belonging to the same country, according to their timezone. You can also skip that and ...


12

The problem seems to be related to mixing geopositions and raw long/lat pairs. pos is expressed as a GeoPosition and the polygon is expressed as raw pairs. The graphics are better behaved if all coordinates are expessed in the same fashion. Option one: use geopositions throughout Change the assignment to {a, b, d, c} from this: {a, b, d, c} = ...


12

Use Interpreter without federal state or country. Works even for small german towns :) Interpreter["City"]["Memmingen"] GeoPosition[%] GeoGraphics[%] EDIT: Also you could ask for the airport: town = Interpreter["City"]["Memmingen"]; airport = Interpreter["Airport"]["Memmingen"]; GeoPosition[{town, airport}] or just use the nearest airport ...


12

You'll need some sort of GeoPosition that you want to zoom in on, then you can set your range: GeoGraphics[Entity["City", {"Eureka", "California", "UnitedStates"}], GeoRange -> Quantity[n, "Miles"]] Where n is your width. EDIT 1 Here is a rough sketch of what a controller would look like: corner1 = GeoBoundingBox[Entity["City", {"Eureka", ...


11

Try this: CityData[#, "Coordinates"] & /@ CityData[All] also if you want the city too {#, CityData[#, "Coordinates"]} & /@ CityData[All] I assume that the option "Coordinates" need a specific city so you have to retrieve all the available cities in the database and then feed each one to CityData to get its coordinates.


11

Comment I've placed a Notebook version of this post on my webspace here: http://facstaff.unca.edu/mcmcclur/polylineDecoder.zip The Notebook is actually contained in a ZIP file that also contains all the Java class files necessary to get this code to work. The Notebook sets the Java class relative to it's own directory using ...


11

You could use the official ICAO abbreviation: Entity["Airport", "KLAX"] which makes sense because you will only be able to use officially named airports most of the time anyway. You can always get those (or the city details) via a W|A query and work your way from there (no googling involved): or like this (although it misses Van Nuys):


11

I really don't get it. But here's work around. It seems that within projected area is everything with longitude in interval: {t-180, t+180} and if you set t = -180 algorithm does not care that it is plotting {-360 , 0} while oryginal data has domain {-180, 180}. We have to take care wbout Mod ourselvs: pos = Cases[ CountryData["World", ...


11

The scheme of the Relief plot can be set using the ColorFunction option. The country border can be shown using Polygon and the location can be labeled using GeoMarker. Here is an example countries = EntityList[EntityClass["Country", "EuropeSovereign"]]; loc = EntityValue[EntityValue[countries, "CapitalCity"], "Position"]; GeoGraphics[{EdgeForm[Red], ...


10

Alternate approach: Graphics[{ {Orange, CountryData[#, "SchematicPolygon"] & /@ MyCountries}, {LightBrown, CountryData[#, "SchematicPolygon"] & /@ Complement[CountryData[], MyCountries]} }] which draws all of "your countries" in one color, and then the rest of the world in another.



Only top voted, non community-wiki answers of a minimum length are eligible