Tag Info

Hot answers tagged

36

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 ...


23

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], ...


21

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], ...


15

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 ...


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

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 ...


10

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 ...


10

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 ...


10

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.


9

I found some free gis data of indian roads. I extracted the india-latest.shp.zip and then imported the roads.shp file. Here is a quick example to extract relevant roads: (* Make sure to fix the path *) indiaRoadData = Import["india-latest.shp/roads.shp", "Data"]; (* This just happens to be where the Lines are located in the data, see below for some ...


9

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.


8

The most likely cause of your problem is that you are swapping lat and long coordinates. Your latlong definition in the .NB file provided goes like this: latlong = {{40.660323`, -73.997952`}, {40.660489`, -73.99822`}, {40.654365`, -74.004113`},... That's New York. Simply plotting without projection gives: m1=Graphics@Point@latlong I seem to see ...


7

You can use the undocumented option OfficialLanguages CountryData["Republic of South Africa", "OfficialLanguages"] {"Afrikaans", "English", "IsiZulu", "IsiXhosa", "Sepedi", "Swati", "Ndebele", "Sesotho", "Xitsonga", "Setswana", "Venda"}


7

I'm not quite sure what you mean by distances in "diagonal matrix" form. Pairwise distances are certainly displayed as matrices, but these are not diagonal (they're symmetric, with zeros along the diagonal). In any case, here's a way to obtain that. I'll define a function cityData that returns the great-circle distance between two cities: ...


6

This seems to work: LatitudeLongitude @ GeoGridPosition[{172248, 1002321, 0}, "SPCS83NY04"] (* {49.145, -75.732} *)


5

I recently implemented a native Mathematica decoder for the encoded Google polyline strings returned during a request to its API. This uses Compile and I found it faster than the above J/Link based solution. I guess it could have been even faster if we could compile the BitShiftLeft and BitShiftRight. But I guess these two functions are pretty optimized in ...


5

The problem comes from rasterization by MorphologicalComponents. Maybe you could avoid it at the first place. mapdata = Import["http://gadm.org/data/shp/FRA_adm.zip", "Data"]; regiondata = "Geometry" /. mapdata[[2]]; departdata = "Geometry" /. mapdata[[1]]; regionNum = Length@regiondata t1 = Graphics@{ Rectangle[{-6, 41}, {9.7, 51.5}], ...


4

bg = Import["sample.shp"] Show[bg, Graphics[Point@Reverse[latlong, {2}]]]


4

The problem is using rectangle at the beginning. Use Background -> Black instead: t1 = Graphics[{EdgeForm[Thick], FaceForm[White], ("Geometry" /. mapdata[[2]])}, Background -> Black, ImageSize -> 600]; t2 = Colorize[MorphologicalComponents[t1, CornerNeighbors -> False], ColorFunction -> "LightTerrain"]; t3 = Show[Graphics@{Black, ...


4

So both CountryData["World", "LandArea"] - (CountryData["Antarctica", "LandArea"] + Total[CountryData[#, "LandArea"] & /@ CountryData[]]) and CountryData["World", "LandArea"] - Total[Flatten[CountryData[#, "LandArea"] & /@ CountryData["Continents"]]] give $3.42636\times10^6 \text{ km}^2$ of area missing. That is approximately the area of ...


3

Here's a quick answer for your first question (I'll let someone else handle the mapping (that's a lot of data to sort through). Let's look at the wonderful (cough) city of Houston. winddata = WeatherData[{"Houston", "Texas"}, "MeanWindSpeed", {{1973, 1, 1}, {2013, 5, 1}, "Day"}]; Gather those values by day: daysorted = GatherBy[winddata, #[[1, {2, ...


3

Mathematica 10 introduced new ways to highlight countries on the world map. Examples follow below. There are lots of more examples in the documentation which showcase alternative stylings. myCountries = Map[ Entity["Country", #] &, {"Germany", "Hungary", "Mexico", "Austria", "Turkey", "SouthKorea", "China"} ]; GeoListPlot[myCountries, ...


2

This is a very simple geocoder that I wrote some time ago. cleanString[string_] := Module[{l1,l2}, l1 = Characters@"ŠŽšžŸÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðñòóôõöùúûüýÿ"; l2 = Characters@"SZszYAAAAAACEEEEIIIIDNOOOOOUUUUYaaaaaaceeeeiiiidnooooouuuuyy"; StringReplace[string, Thread[l1 -> l2]~Join~{" " -> "%20", "," -> "%2C"}] ] ...


2

As @Spawn1701D mentioned, you have to retrieve the data then map CityData across it. You can also just look at specific cities instead of loading every city in the world which seems like it would be unnecessary for some situations. For example to get just data about cities in New York you can do: CityData[#, "Coordinates"] & /@ CityData[{All, ...


2

The fastest is probably with the use of the GeoNames API*: loc = FindGeoLocation[] i = Import[ "http://api.geonames.org/findNearby?lat=" <> ToString[loc[[1]]] <> "&lng=" <> ToString[loc[[2]]] <> "&username=demo", "XML"]; name = Cases[i[[2, 3, 1, 3]], XMLElement["name", _, x_] -> x] *Idea from this post. EDIT: another ...


2

One way is to do this: nc = Nearest[ CityData[#, "Coordinates"] -> # & /@ CityData[{All, "United Kingdom"}]]; Then use this as: nc[FindGeoLocation[]] {{"London", "GreaterLondon", "UnitedKingdom"}}


2

The following solution proceeds similarly to Vitaliy's, but preserves the coordinates of France's departments: france = Import["http://gadm.org/data/shp/FRA_adm.zip", "Data"]; provinces = Colorize[MorphologicalComponents[ Graphics[{EdgeForm[Thick], FaceForm[White], "Geometry" /. france[[2]]}, Background ...


2

Your [[1,2]] takes the first windspeed from every location. So, it doesn't help to increase the data range. [[All,2]] results in passing a list of windspeeds for every location to ListContourPlot. However, ListContourPlot expects a single dependent value for each point not a list. How would you interpret that? You need to apply Mean on that list to get a ...


2

I am assuming you have Mathematica with you. So here's some quick and dirty way to get the info you require. I think it is very interesting to do this currentLocation = GeoPosition[ CountryData[ StringTrim[ StringSplit[ WolframAlpha[ "Current GeoIP location", {{"HostInformationPod", 1}, "ComputableData"}][[2, ...


1

what about. {#, WolframAlpha[ StringJoin["Official Language ", #], {{"Result", 1}, "ComputableData"}]} & /@ {"Argentina", "Belgium", "Belarus", "Ireland", "Ukraine"} (*{{"Argentina", {"Spanish"}}, {"Belgium", {"Dutch", "French", "German"}}, {"Belarus", {"Belarusan","Russian"}}, {"Ireland",{"English",""}}, ...



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