1
$\begingroup$

My question is about making a animiation using 'manipulate' using DateObject as parameter. I start with importing a file.txt, like:

   data = Import["filename.txt", 
      "Table", {"FieldSeparators" -> "|", "CharacterEncoding" -> "ASCII", 
       "EmptyField" -> "", "RepeatedSeparators" -> False, 
       "HeaderLines" -> 1, 
       "DateStringFormat" -> {"Day", "-", "Month", "-", "Year"}, 
       "NumberPoint" -> ","}]

For your information, the filename.txt looks like this:

DATE|ZIPCODE|FREQ|LONGITUDE|LATITUDE 01-01-14|1011PL|61|4,9023874104022997|52,366754114627803 01-01-14|1012JW|4|4,8945593833923304|52,374049723148303 01-01-14|1013LC|275|4,8862525820732099|52,302816957235301 01-01-14|1013WN|50|4,8738205432891801|52,390252947807298 01-01-14|1015AE|55|4,8903188109397897|52,375850826501797 01-01-14|1015CR|73|4,8884466290473902|52,302816957235301 01-01-14|1015DT|312|4,8770217597484598|52,302816957235301 01-01-14|1016HP|118|4,8770217597484598|52,302816957235301 01-01-14|1016RS|15|4,8787397146225002|52,371013462543502 01-01-14|1017NP|60|4,8856249451637304|52,302816957235301 01-01-14|1017PX|52|4,7597301006317103|52,362340539693797 01-01-14|1018AM|154|4,9260766804218301|52,367431372404099

I would like to make a animation with the GeoGraphics function: A Google.maps background with plotted some transaction history. So I created a new dataset: data1

data1 = Map[{#[[1]], #[[3]], GeoPosition[{#[[5]], #[[4]]}]} &, data]

Then I create a Google.maps graphic:

GeoGraphics[{{Red, Opacity[.4], PointSize[#2*0.0001], Point[#3]} & @@@
    data1}, GeoRange -> {{50.77119, 53.47875}, {3.437263, 7.187985}}, 
 GeoScaleBar -> "Metric", ImageSize -> Large]

I want to make a animation based on the first column (data). For every new date in the file a want to see a new graphic. The result must be a animation. I tried many option. For me, a logical option is de folllowing:

Manipulate[
 GeoGraphics[{{Red, Opacity[.4], PointSize[#2*0.0001], Point[#3]} & @@@
     Select[data1[[All, {1, 2, 3}]], #[[1]] == date &]}, 
  GeoScaleBar -> "Metric", ImageSize -> Large, 
  GeoRange -> {{50.77119, 53.47875}, {3.437263, 
     7.187985}}], {date, {DateRange[DateObject[{2014, 1, 1}], 
    DateObject[{2014, 1, 15}]], "Days"}, SaveDefinitions -> True}]

This script doesn't work. Anyone a idea how I can use DataeObject as a parameter within the manipulate function?

$\endgroup$
1
  • $\begingroup$ As far as I know the maps are not from Google but from OpenStreetmap. $\endgroup$ Nov 11, 2014 at 21:13

1 Answer 1

4
$\begingroup$

There were several errors in your Manipulate variable specification:

  • "Days" outside of the DateRange function brackets

  • "Days" instead of "Day"

  • {} around DateRange: this function generates a list itself, nothing else is needed.

  • SaveDefinition option within the date specification list, instead of as an option of Manipulate

Furthermore, you have your dates in the input file as "YearShort"s ('14' instead of '2014'), so you have to Import them that way using "YearShort" instead of "Year".

The working code:

Manipulate[
 GeoGraphics[{Red, Opacity[.4], PointSize[#2*0.0001], Point[#3]} & @@@
    Select[data1[[All, {1, 2, 3}]], #[[1]] == date &],
  GeoScaleBar -> "Metric",
  GeoRange -> {{50.77119, 53.47875}, {3.437263, 7.187985}},
  ImageSize -> Large
  ],
 {date, DateRange[DateObject[{2014, 1, 1}], DateObject[{2014, 1, 15}], "Day"]},
 SaveDefinitions -> True
 ]

Mathematica graphics

For an animation, just change Manipulate into Animate.

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.