# Rendering a map

**URL:** <https://talk.observablehq.com/t/rendering-a-map/5876>\
**Category:** Help\
**Created:** [November 28, 2021, 6:06am UTC](https://talk.observablehq.com/t/rendering-a-map/5876 "2021-11-28T06:06:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ofure](https://avatars.discourse-cdn.com/v4/letter/o/d07c76/32.png) [@Ofure](https://talk.observablehq.com/u/Ofure)\
**Post date:** [November 28, 2021, 6:06am UTC](https://talk.observablehq.com/t/rendering-a-map/5876/1 "2021-11-28T06:06:29Z")

</div>

Hi everyone! I’m new here and new to d3. Glad to be here I’m working on a project and I am trying to render a map of massachusetts so that I can use it to play around and practice some interactions. However, nothing I have tried seems to display the map.  
Backstory: I got the GIS data from mass[dot]gov and used [mapshaper.org](http://mapshaper.org) to convert the shp files into geojson and topojson files. However, after importing the data and defining the projections and all I need, the map doesnt render. I’ve tried forking different notebooks that work and using my data there but it still doesnt work. I don’t know if my problem is the data or my methods, and I’ll appreciate it if someone can help take a look. Thanks

> **[Exploring Massachusetts restaurants](https://observablehq.com/d/23525c7d79507815)**
>
> Star Ratings per Price level Configuration Mapping tools Data Dependencies

---

<div class="post-metadata">

**Author:** ![hellonearthis](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/hellonearthis/32/3935_2.png) [@hellonearthis](https://talk.observablehq.com/u/hellonearthis)\
**Post date:** [November 28, 2021, 6:43am UTC](https://talk.observablehq.com/t/rendering-a-map/5876/2 "2021-11-28T06:43:05Z")

</div>

Inspecting the SVG with the debugger it looks like there are issues with way the svg is made, lots of NAN

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/observablehq/original/2X/9/9ec81f69b76ecb76bca7544b04c44904b0da8149.png)

Adding to the shows one pie chart. But doesnt fix the nans

```auto
// map showing the counties/zips with the most popular restaurants
projection = d3
  .geoConicConformal()
  .parallels([34 + 2 / 60, 35 + 28 / 60])
  .rotate([118, 0])
  .scale(width)
  .center([34, 35])
  .translate([width / 2, height / 2])
  .clipExtent([[0, 0], [width, height]])
  .precision(0.2)

```

Adding a stroke colour might also help.

```auto
    .join('path')
     .attr('d', path)
      .attr('stroke', '#00F')

```

This notebook might also be of help. [Massachusetts Coronavirus Cases by Town / Harris Lapiroff / Observable](https://observablehq.com/@harrislapiroff/massachusetts-covid-cases-town-by-town)

---

<div class="post-metadata">

**Author:** ![Fil](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fil/32/207_2.png) [@Fil](https://talk.observablehq.com/u/Fil)\
**Post date:** [November 28, 2021, 1:48pm UTC](https://talk.observablehq.com/t/rendering-a-map/5876/3 "2021-11-28T13:48:00Z")

</div>

Hello Ofure,

looking at the coordinates in the counties\_geo file it appears that they are already projected in a metric space (X, Y), and not (longitude, latitude). So the projection to use to display them should be `d3.geoIdentity().reflectY(true)` (we need to reflect vertically because svg’s coordinate system has y going “down”, but metric projections have y pointing “up”).

OTOH the mass\_restos file uses longitudes and latitudes, so you might have a hard time adjusting two different projections. If you can find the exact definition for the original shape file’s projection (often called a CRS), it would definitely help.

---

<div class="post-metadata">

**Author:** ![Ofure](https://avatars.discourse-cdn.com/v4/letter/o/d07c76/32.png) [@Ofure](https://talk.observablehq.com/u/Ofure)\
**Post date:** [November 28, 2021, 7:34pm UTC](https://talk.observablehq.com/t/rendering-a-map/5876/4 "2021-11-28T19:34:53Z")

</div>

Thank you so much @hellonearthis for this. I’m not really sure how to fix the SVG but I was wondering why using this code that you shared, I see a pie chart now and not the shape of the state of massachusetts. I’m a bit confused as to what is being rendered.

---

<div class="post-metadata">

**Author:** ![Ofure](https://avatars.discourse-cdn.com/v4/letter/o/d07c76/32.png) [@Ofure](https://talk.observablehq.com/u/Ofure)\
**Post date:** [November 28, 2021, 7:41pm UTC](https://talk.observablehq.com/t/rendering-a-map/5876/5 "2021-11-28T19:41:08Z")

</div>

Omggg. So I was using the wrong projection all along! Thanks for pointing that out. I was also wondering why the coordinates were strange-looking and not in (lat,long) format. I now understand that are projected in a metric space and not in (lat,long).

OTOH I have a file with the .prj extension and I assume it is supposed to be for the projection, but I dont have the CRS file. I’ll try to see if I can get one. Thank you so much, @Fil

---

<div class="post-metadata">

**Author:** ![Fil](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fil/32/207_2.png) [@Fil](https://talk.observablehq.com/u/Fil)\
**Post date:** [November 28, 2021, 8:00pm UTC](https://talk.observablehq.com/t/rendering-a-map/5876/6 "2021-11-28T20:00:51Z")

</div>

yes the prj file should give you the projection definition, which you can apply with proj4; see for example [Using proj4js with d3 / Fil / Observable](https://observablehq.com/@fil/proj4js-d3)
