Our World Statistics Day conversations have been a great reminder of how much statistics can inform our lives. Do you have an example of how statistics has made a difference in your life? Share your story with the Community!
Choose Language Hide Translation Bar
Highlighted

Adding Map to 3D Scatter Plot

Hi all, 


Does anyone know if a map can be appended to a wall of a 3D scatter plot as either an attachment graphic on the wall or a background map similar to what is done in the 2D scatter plot? 

I have lat, long data as the x & y and depth as the z axis so it would be very advantageous to have a map in the x/y plane. 

Please let me know if this can be done through either custom scripting or any other methods. 
Thanks. 

1 REPLY 1
Highlighted
Craige_Hales
Staff (Retired)

Re: Adding Map to 3D Scatter Plot

I think the 3D platforms can't do that. @Paul_Nelson . 3D Effects, Satellites, GPS shows a crude way to simulate texture mapping, but you'd be writing JSL and have to re-invent axes and labels and selection and etc. 

You might use a 2D platform like this (code at end, first 80% is setup):

 

// attribution: https://simplemaps.com/data/world-cities
za = 0; // clear prev run
za = Open( "https://simplemaps.com/static/data/world-cities/basic/simplemaps_worldcities_basicv1.6.zip", "zip" );
blob = za << read( "worldcities.csv", Format( blob ) );
dt = Open(
	blob,
	columns(
		New Column( "city", Character, "Nominal" ),
		New Column( "city_ascii", Character, "Nominal" ),
		New Column( "lat", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "lng", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "country", Character, "Nominal" ),
		New Column( "iso2", Character, "Nominal" ),
		New Column( "iso3", Character, "Nominal" ),
		New Column( "admin_name", Character, "Nominal" ),
		New Column( "capital", Character, "Nominal" ),
		New Column( "population", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "id", Numeric, "Continuous", Format( "Best", 12 ) )
	),
	Import Settings(
		End Of Line( CRLF, CR, LF ),
		End Of Field( Tab, Comma, CSV( 1 ) ),
		Strip Quotes( 1 ),
		Use Apostrophe as Quotation Mark( 0 ),
		Use Regional Settings( 0 ),
		Scan Whole File( 1 ),
		Treat empty columns as numeric( 0 ),
		CompressNumericColumns( 0 ),
		CompressCharacterColumns( 0 ),
		CompressAllowListCheck( 0 ),
		Labels( 1 ),
		Column Names Start( 1 ),
		Data Starts( 2 ),
		Lines To Read( 500 ), // there are 15,000; that's too much clutter
		Year Rule( "20xx" )
	)
);
dt:city << label;
gb = dt << Graph Builder(
	Size( 1326, 715 ),
	Show Control Panel( 0 ),
	Show Legend( 0 ),
	Show Footer( 0 ),
	Variables( X( :lng ), Y( :lat ) ),
	Elements( Points( X, Y, Legend( 5 ) ) ),
	SendToReport(
		Dispatch( {}, "Graph Builder", OutlineBox, {Set Title( "" ), Image Export Display( Normal )} ),
		Dispatch(
			{},
			"lng",
			ScaleBox,
			{Scale( "Geodesic" ), Min( -180 ), Max( 180 ), Inc( 90 ), Minor Ticks( 0 ),
			Label Row( {Show Major Labels( 0 ), Show Major Ticks( 0 ), Show Minor Ticks( 0 )} )}
		),
		Dispatch(
			{},
			"lat",
			ScaleBox,
			{Scale( "Geodesic" ), Format( "Best", 12 ), Min( -90 ), Max( 90 ), Inc( 45 ), Minor Ticks( 1 ), Label Row(
				{Show Major Labels( 0 ), Show Major Ticks( 0 ), Show Minor Ticks( 0 )}
			)}
		),
		Dispatch( {}, "graph title", TextEditBox, {Set Text( "Big City Population" )} ),
		Dispatch( {}, "X title", TextEditBox, {Set Text( "" )} ),
		Dispatch( {}, "Y title", TextEditBox, {Set Text( "" )} ),
		Dispatch(
			{},
			"Graph Builder",
			FrameBox,
			{Background Map( Boundaries( "World" ) ), Marker Size( 0 ), Left( 0 ), Right( 0 ), Top( 0 ), Bottom( 0 ), Grid Line Order( 2 ),
			Reference Line Order( 4 )}
		)
	)
);


// add small lines

Report( gb )[framebox( 1 )] << Add Graphics Script(
	Pen Color( "red" );
	For( i = 1, i <= N Rows( dt ), i += 1,
		Pen Size( population[i] / 1e6 );
		Pixel Origin( :lng[i], :lat[i] );
		Pixel Move To( 0, 0 );
		Pixel Line To( 20 * population[i] / 30e6, -100 * population[i] / 30e6 );
	);
	// text on top
	For( i = 1, i <= N Rows( dt ), i += 1,
		If( population[i] >= 12e6,
			Text Size( 12 );
			Text( centerjustified, {:lng[i], :lat[i]}, city[i] );
		)
	);
);

Not really 3DNot really 3D

 

 

Craige
Article Labels