0

I've asked similar questions before and I'm still struggling.

I want to create geo based info graphics at the level of a city.

I need to be able to take some latitude/longitude values and project them such that they are centered and appropriately zoomed.

It would help me a great deal to see an example that plots a small number of points.

  • 37.781040, -122.497681
  • 37.720504, -122.495622
  • 37.723220, -122.395028

This is roughly an L shape and all three points should be in San Francisco.

It could be as simple as 3 black dots on a white background. I hope to learn:

  • which projection?
  • how do you adjust the projection so that an area the size of San Francisco is on the canvas?
  • how do you translate those coordinates and position them on that canvas?

Could someone create such an example?

Thanks.

-Kelly

kellyfelkins
  • 141
  • 1
  • 7
  • Have you seen [this question](http://stackoverflow.com/questions/14492284/center-a-map-in-d3-given-a-geojson-object)? – Lars Kotthoff Mar 23 '14 at 01:17
  • Yes, I've seen that. Thank you. One problem is that I don't have or need paths or shape files and that question uses shape files to discover the bounding box. I really hope to see a simple example that includes the lat/longs as data. I suspect that the trouble I'm having is simple - like I need to convert my lat/longs in some way, swap and/or negate them. – kellyfelkins Mar 23 '14 at 16:23
  • I guess I'm looking for a geo example that is at the city level that doesn't use shape files. – kellyfelkins Mar 23 '14 at 16:33

1 Answers1

0

I created a simple example that works.

https://gist.github.com/kellyfelkins/9741723

I think I was making multiple mistakes that made it really difficult to correct.

In case others have troubles too, here are some things to watch out for:

  1. The projection method expects an array. For a while I was passing it 2 arguments, but it needs a single argument that is an array.
  2. The projection expects the values in longitude, latitude order.

-Kelly

kellyfelkins
  • 141
  • 1
  • 7