# Cannot display geojson, error "Expected number"

**URL:** <https://talk.observablehq.com/t/cannot-display-geojson-error-expected-number/9444>\
**Category:** Help\
**Created:** [June 28, 2024, 11:17am UTC](https://talk.observablehq.com/t/cannot-display-geojson-error-expected-number/9444 "2024-06-28T11:17:39Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sourajit](https://avatars.discourse-cdn.com/v4/letter/s/dbc845/32.png) [@Sourajit](https://talk.observablehq.com/u/Sourajit)\
**Post date:** [June 28, 2024, 11:17am UTC](https://talk.observablehq.com/t/cannot-display-geojson-error-expected-number/9444/1 "2024-06-28T11:17:39Z")

</div>

I am doing a GIS project. I have downloaded the shape files for my country, India, containing the district (an administrative unit) map. I have converted the shapefiles to GeoJSON.

Now, I am trying to plot it. But it results in the following error. This error is thrown as many times for each GIS feature in that GeoJSON.

\_esm.js:7 Error: attribute d: Expected number, “…L305.904,56.801LNaN,NaNLNaN,NaNL…”.

Here is my code.

```js
const geojson = await FileAttachment("data/output.geojson").json();
const projection = d3.geoConicConformal()
               .parallels([12.472944, 35.172806]);
               /*
               .rotate([-80, 0])
               .scale(1000);
               .translate([width / 2, height / 2]);*/

Plot.plot({
    projection: projection,
    marks : [
        Plot.geo(geojson, {
            title: (d) => `${d.STATE} ${d.District}`,
            tip: true
        })
    ]
});

```

I had even reduced the decimal point precision of the points in the GeoJSON to 6. Still I get the same error.

What mistake am I making ?

---

<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:** [June 28, 2024, 11:33am UTC](https://talk.observablehq.com/t/cannot-display-geojson-error-expected-number/9444/2 "2024-06-28T11:33:55Z")

</div>

can you share the file?

---

<div class="post-metadata">

**Author:** ![Sourajit](https://avatars.discourse-cdn.com/v4/letter/s/dbc845/32.png) [@Sourajit](https://talk.observablehq.com/u/Sourajit)\
**Post date:** [June 28, 2024, 11:51am UTC](https://talk.observablehq.com/t/cannot-display-geojson-error-expected-number/9444/3 "2024-06-28T11:51:44Z")

</div>

How can I attach the file here ?

---

<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:** [June 28, 2024, 12:08pm UTC](https://talk.observablehq.com/t/cannot-display-geojson-error-expected-number/9444/4 "2024-06-28T12:08:34Z")

</div>

I don’t think that is possible. You could attach it to an observable notebook, or share it as a gist.

---

<div class="post-metadata">

**Author:** ![Sourajit](https://avatars.discourse-cdn.com/v4/letter/s/dbc845/32.png) [@Sourajit](https://talk.observablehq.com/u/Sourajit)\
**Post date:** [June 29, 2024, 8:04am UTC](https://talk.observablehq.com/t/cannot-display-geojson-error-expected-number/9444/5 "2024-06-29T08:04:52Z")

</div>

I have created an archive of the output.geojson file called output.7z and uploaded it to [GitHub - SourajitBasak/observable: Repo for storing observable samples](https://github.com/SourajitBasak/observable).

You can use the 7-Zip software to deflate it.

---

<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:** [June 29, 2024, 8:23am UTC](https://talk.observablehq.com/t/cannot-display-geojson-error-expected-number/9444/6 "2024-06-29T08:23:15Z")

</div>

The coordinates in this file are already projected—they are not longitude and latitudes in degrees, but (possibly) meters on a plane.

You can use `projection: {type: "reflect-y", domain: geojson}` to display this data:

 ![Capture d’écran 2024-06-29 à 10.22.10](https://canada1.discourse-cdn.com/flex030/uploads/observablehq/original/2X/6/6477ef698c2e5a1cfb6f9fb07e4d000efcee1e11.png)

---

<div class="post-metadata">

**Author:** ![Sourajit](https://avatars.discourse-cdn.com/v4/letter/s/dbc845/32.png) [@Sourajit](https://talk.observablehq.com/u/Sourajit)\
**Post date:** [June 29, 2024, 9:23am UTC](https://talk.observablehq.com/t/cannot-display-geojson-error-expected-number/9444/7 "2024-06-29T09:23:38Z")

</div>

Maybe I am making a silly mistake. But this code does not create any map of the browser screen. There are no errors as well.

BTW what does this projection mean ?

```js
const geojson = await FileAttachment("data/output.geojson").json();
console.log(geojson);

Plot.plot({
    projection: {type: 'reflect-y', domain: geojson},
    marks : [Plot.geo(geojson)]
});

```

---

<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:** [June 29, 2024, 11:45am UTC](https://talk.observablehq.com/t/cannot-display-geojson-error-expected-number/9444/8 "2024-06-29T11:45:40Z")

</div>

In Observable Framework you have to use `display(…)` to put the chart on the screen, unless it is an expression (single line of code, without a semi-colon).  
see [JavaScript | Observable Framework](https://observablehq.com/framework/javascript#explicit-display)

Projections are documented here:

> **[Projections | Observable Plot](https://observablehq.com/plot/features/projections)**
>
> The JavaScript library for exploratory data visualization

---

<div class="post-metadata">

**Author:** ![Sourajit](https://avatars.discourse-cdn.com/v4/letter/s/dbc845/32.png) [@Sourajit](https://talk.observablehq.com/u/Sourajit)\
**Post date:** [June 29, 2024, 12:27pm UTC](https://talk.observablehq.com/t/cannot-display-geojson-error-expected-number/9444/9 "2024-06-29T12:27:08Z")

</div>

Thanks a lot for your support.

---

<div class="post-metadata">

**Author:** ![Sourajit](https://avatars.discourse-cdn.com/v4/letter/s/dbc845/32.png) [@Sourajit](https://talk.observablehq.com/u/Sourajit)\
**Post date:** [June 29, 2024, 12:35pm UTC](https://talk.observablehq.com/t/cannot-display-geojson-error-expected-number/9444/10 "2024-06-29T12:35:59Z")

</div>

```js
display(Plot.plot({
                    projection: {type: 'reflect-y', domain: geojson},
                    marks : [Plot.geo(geojson, {
                        title: (d) => `${d.properties.STATE} ${d.properties.District}`
                    })]})
);

```

The title (popup on hover) does not work as expected.

---

<div class="post-metadata">

**Author:** ![Sourajit](https://avatars.discourse-cdn.com/v4/letter/s/dbc845/32.png) [@Sourajit](https://talk.observablehq.com/u/Sourajit)\
**Post date:** [June 29, 2024, 1:12pm UTC](https://talk.observablehq.com/t/cannot-display-geojson-error-expected-number/9444/11 "2024-06-29T13:12:39Z")

</div>

Well, I have converted the shapefile to a geojson i.e. EPSG:4326 (WGS 84) where the co-ordinates are latitude and longitude. Thereafter, I have used the following code to display the map. It is showing up, but how do I adjust the parallels and rotate it and magnify it to show the map properly.

```js
display(Plot.plot({
                    projection: { type: "conic-conformal"},
                    marks : [Plot.geo(geojson, {
                        title: (d) => `${d.properties.STATE} ${d.properties.District}`,
                        tip: true
                    })]})
);

```

India government uses Lambert Conic Conformal projections and the shapefile has that Co-ordinate reference system.

---

<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:** [June 29, 2024, 1:36pm UTC](https://talk.observablehq.com/t/cannot-display-geojson-error-expected-number/9444/12 "2024-06-29T13:36:28Z")

</div>

The title will work better if you fill the shapes (e.g. with an option such as `fill: 'white', stroke: 'black'`)

Projections are documented in details at the link provided above. There are many options that allow you to control rotation, scale etc.
